/***************************************************************************** 
* 
* File Name : wm_adc_demo.c 
* 
* Description: adc demo function 
* 
* Copyright (c) 2014 Winner Micro Electronic Design Co., Ltd. 
* All rights reserved. 
* 
* Author : dave
* 
* Date : 2014-8-18
*****************************************************************************/ 
#include "wm_include.h"
#if DEMO_DSP
#include <stdio.h>
#include "csky_math.h"
#include "csky_const_structs.h"


#define TAP_NUM  28
#define FIR_SIZE 320

q15_t fir_src[FIR_SIZE] = {
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
    0x0000, 0x5e22, 0x3b17, 0xf7bc, 0x0df3, 0x3333, 0x0df3, 0xf7bc,
    0x3b17, 0x5e22, 0x0000, 0xa1de, 0xc4e9, 0x0844, 0xf20d, 0xcccd,
    0xf20d, 0x0844, 0xc4e9, 0xa1de, 0x0000, 0x5e22, 0x3b17, 0xf7bc,
    0x0df3, 0x3333, 0x0df3, 0xf7bc, 0x3b17, 0x5e22, 0x0000, 0xa1de,
    0xc4e9, 0x0844, 0xf20d, 0xcccd, 0xf20d, 0x0844, 0xc4e9, 0xa1de,
};

q15_t ref_fir_result[FIR_SIZE] = {
    0x0000, 0x0000, 0x0019, 0x0043, 0x006a, 0x0078, 0x003d, 0xff7a,
    0xfe41, 0xfd23, 0xfd06, 0xfec8, 0x02e8, 0x092e, 0x108d, 0x1779,
    0x1cb9, 0x1ff5, 0x2193, 0x2225, 0x21ea, 0x207f, 0x1cec, 0x1641,
    0x0c68, 0x0078, 0xf43e, 0xe97c, 0xe16e, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
    0x24e4, 0x235c, 0x1eab, 0x16c7, 0x0c2b, 0x0000, 0xf3d4, 0xe938,
    0xe154, 0xdca3, 0xdb1b, 0xdca3, 0xe154, 0xe938, 0xf3d4, 0x0000,
    0x0c2b, 0x16c7, 0x1eab, 0x235c, 0x24e4, 0x235c, 0x1eab, 0x16c7,
    0x0c2b, 0x0000, 0xf3d4, 0xe938, 0xe154, 0xdca3, 0xdb1b, 0xdca3,
    0xe154, 0xe938, 0xf3d4, 0x0000, 0x0c2b, 0x16c7, 0x1eab, 0x235c,
};

q15_t fir_coeffs[FIR_SIZE] = {
    0x0023, 0x0046, 0x0068, 0x0064, 0x0000, 0xff19, 0xfde3, 0xfd05,
    0xfd71, 0x0000, 0x04f0, 0x0b97, 0x1272, 0x179d, 0x1989, 0x179d,
    0x1272, 0x0b97, 0x04f0, 0x0000, 0xfd71, 0xfd05, 0xfde3, 0xff19,
    0x0000, 0x0064, 0x0068, 0x0046, 0x0023,
};

q15_t fir_states[FIR_SIZE * 2];
q15_t fir_result[FIR_SIZE * 2];
int dsp_fir_demo(void)
{
    uint16_t tap;
    uint16_t block_size;
    csky_fir_instance_q15 S;
    int i;

    tap = TAP_NUM + 2;
    block_size = FIR_SIZE;

    csky_fir_init_q15(&S, tap, fir_coeffs, fir_states, block_size);

    csky_fir_q15(&S, fir_src, fir_result, block_size);

    for (i = 0; i < block_size; i++) {
        if (fir_result[i] != ref_fir_result[i]) {
            printf("dsp fir run failure!\n");
			return -1;
        }
    }

    printf("dsp fir run success!\n");
    return 0;
}



#define MAT_ROW             16
#define MAT_COL             16
#define MAT_SIZE            16 * 16

q31_t data_src0[MAT_SIZE] = {
    0x3e6386a, 0x5f9e7e7, 0x7b63e96, 0x8d5e856, 0x73be7bf, 0x1248208, 0xd9b2873, 0x692a55c,
    0x06eb1b7, 0xe24827e, 0x8d6fb14, 0x7d92249, 0x92e74d1, 0xf9d3352, 0x0c4a540, 0x7e4bb61,
    0xcd4cd29, 0x91fa08c, 0x0378df1, 0x2eed447, 0x79d190d, 0x7b5293b, 0xfa7ecfd, 0x629dc7d,
    0x9e6d2b1, 0xc29cd59, 0x4d19a1c, 0xb9fe299, 0x9ed99f8, 0xde49a1d, 0x111dca9, 0xdb51116,
    0x96f0cec, 0x7ccf56b, 0x7e1a5dc, 0x1bca8dd, 0x87ea03e, 0x5984c2c, 0x166011b, 0x4b6a366,
    0xe1510d0, 0x60a1d7f, 0x2db6aca, 0xe5e3aaf, 0x7b49e39, 0x27d620e, 0x2e2e5db, 0x40bb4a9,
    0x5372794, 0x6c36f28, 0xf4b22c4, 0xb83b5f1, 0xfe6f0a5, 0xc88fcc5, 0xa55385a, 0x6d01df1,
    0x5015caf, 0x4e5c4e6, 0x722da46, 0x3252535, 0xff2e3f3, 0x702de6d, 0xdf12aa9, 0x9c2c236,
    0xe3bbf96, 0x1073675, 0xed1103e, 0xe801f65, 0x5cdb5b7, 0x2eb58ba, 0x67c3bf2, 0xadc8747,
    0xbe7d11e, 0xf60c07f, 0x97705ab, 0x908c4bf, 0x85bce6b, 0x1ed42f5, 0x9406cbf, 0x18d7f4c,
    0x467a60f, 0xee744c1, 0xb6953e6, 0x2141a5a, 0xbe2d21e, 0xdbae0c9, 0x23e3c53, 0x047d93a,
    0x626985f, 0x974943e, 0x688f6ac, 0x3f66bfd, 0x8dc7e78, 0xc868354, 0xf4d366a, 0xee3b7ca,
    0xadeb220, 0xd67cfb3, 0xb178cc4, 0x0e28a3f, 0x5592bab, 0x7ca73b9, 0xa9b6686, 0x20836ba,
    0x3670053, 0x1073ebf, 0x028c484, 0xeb9f5cd, 0xa4104e2, 0xb486c22, 0x8c3f7dc, 0x3b10560,
    0x9bff18a, 0x388154a, 0x552f61d, 0xa0a9057, 0x5047832, 0x9580203, 0x10df843, 0x69c6517,
    0xe0ce560, 0xaff8533, 0x1d6a51e, 0x4fb27f9, 0x64babb8, 0xf06b175, 0x3cfe690, 0xc2dc710,
    0x67b874f, 0x837eee6, 0x3a04e39, 0xab5094f, 0x210461a, 0xc0140be, 0x6e7e652, 0x29f9d2d,
    0xbfb9321, 0x081ccf0, 0xd0ea0ac, 0xe12dcfe, 0xf73ffbf, 0x86f9ded, 0x89ba77f, 0x984550f,
    0x60588a1, 0xdfc268a, 0x079d69e, 0x80417f7, 0x8092aeb, 0x4fb4696, 0x48795d7, 0xe3a2240,
    0xc0bb05e, 0xdae376b, 0x93d6383, 0xd1ae6db, 0x0f944ea, 0x604d9dd, 0x74495b2, 0xf37257d,
    0x7ff267c, 0x6c35193, 0x543ea29, 0xeb0cb21, 0xe135968, 0x959cc0a, 0x2f89313, 0x3d71230,
    0x446a138, 0xd095a6d, 0x59c1d7e, 0x7c6dd7b, 0xfe94b0f, 0x1c2f016, 0x3e0c1d0, 0x23dbec5,
    0x5d3fcb8, 0x0be6171, 0x030a33e, 0xfd0d65b, 0x678721b, 0x0800428, 0xf75a25a, 0x515084a,
    0x8cc3bf9, 0x3a0bba9, 0xa4ffb72, 0x37dab42, 0x915a63c, 0xb41ea15, 0x6ffcb1e, 0xa1cd4bc,
    0x8970ce2, 0xf950a66, 0x0d4d5f1, 0xa8ed2a1, 0x2e2b86d, 0x4cf5a0a, 0xc2a434e, 0x19b0324,
    0x2f6f125, 0x0409b0a, 0xded8282, 0xe9c6627, 0x65cc29e, 0x051944d, 0x036bd27, 0xf3ec2bb,
    0x0b704ef, 0xff1d11d, 0xb699d6b, 0x2ab5eed, 0xe0fa8d7, 0x3d23851, 0x11bb8f1, 0x95c25e1,
    0x1eca8c0, 0x4a67b43, 0x1f550b8, 0x993fd4c, 0xc9df6a8, 0x8dc76df, 0xbdabefd, 0x26f68d8,
    0x7f63c62, 0xcf18ba9, 0x167b699, 0x84966de, 0x21c7c8a, 0xa444066, 0xbfaf6f2, 0x6c1fa76,
    0x3f26b95, 0xb459a03, 0x7f5f8fb, 0x3c0c111, 0xc4e0408, 0x5cb850c, 0xc28d15a, 0x53b629a,
    0x02d16e2, 0x736a171, 0xa48c217, 0x9ea30b4, 0xbe46e95, 0xf019d68, 0xd1bdbfc, 0x8db8962,
    0x7a2d6d1, 0x2d985c2, 0x0470aa4, 0x2326814, 0x181d1c0, 0xf1642a9, 0x424c217, 0xcede20d,
};

q31_t data_src1[MAT_SIZE] = {
    0xe7014cad, 0xfabb35de, 0x6a5caca5, 0x3aa21c61, 0x0434ea19, 0x356daa70, 0x003d994e, 0x5ef41f8b,
    0xbfbb5627, 0x3d063e39, 0xd8bdf7e0, 0x83c78d29, 0xd46c70ba, 0x055674ed, 0x5d795568, 0x49f050a0,
    0x625cfbc9, 0x10a3957e, 0x6545d05e, 0xb3dea603, 0x81ec0157, 0x7e308eef, 0xd4fdc98d, 0x390c46b0,
    0xe2ec9acb, 0x79f7e096, 0xd5a99db7, 0x33e864e8, 0xb448c9f4, 0xb8157431, 0x916a4352, 0xf918893d,
    0x33592dc4, 0xfd57b242, 0xfb858dbe, 0xb75de09d, 0x305defda, 0xa9980f16, 0xac839aff, 0x2b07adfb,
    0xee726af2, 0x05f6ed55, 0x131a1233, 0x01ba2e6b, 0x44682f5a, 0x57a6bbd2, 0x77f2a072, 0x542c591e,
    0xbdeb57bd, 0xc512600a, 0xf157683d, 0x79f10f0b, 0x722e642e, 0x9d12aeff, 0x2029b4ef, 0xadc7a880,
    0x54b4fa07, 0xee0eede1, 0x5d2b046a, 0xe19aa7b0, 0x91e9c2a2, 0x29b5f89c, 0x994817fa, 0xd28e2742,
    0x4284567f, 0x7d5f9c26, 0xcfcf2c2c, 0x17de4d07, 0x5fa015d0, 0x69b23434, 0x133c0952, 0x0ced437a,
    0x531c0dd1, 0xb5084fe6, 0xb2d5078d, 0x909f5a63, 0x73356cc1, 0x50f4cbb0, 0x0c06b0ba, 0x79e4bd45,
    0xca7a1bef, 0xaf055ed5, 0x8e290b1a, 0xcded6495, 0x9cffaf83, 0xfb4ddf33, 0x40409402, 0x75ba5f87,
    0xf3f7b791, 0xd2ca6ecc, 0x2c25bf11, 0xdbcbe574, 0xa8806fbc, 0x4b3b8ff9, 0xe7290934, 0xc738d6b7,
    0xc7063951, 0x5c9588fe, 0x40f87f67, 0x77bb604c, 0xdac50e6d, 0x5a0ff472, 0xa74d0210, 0x1894e055,
    0xe16c642c, 0x9c61fd9a, 0x66de6bb5, 0xbbf7e3b2, 0xc954842c, 0xf8174754, 0x9b66fbcf, 0x92a50a25,
    0x819047ee, 0x885a9bb6, 0xa1c74f5e, 0x655e4761, 0xbdef9277, 0x4f5682d1, 0xdb5667dd, 0x4efe7d6f,
    0x6d05b888, 0xe00dc420, 0xb2fbf70e, 0xb418d774, 0x2fe7b194, 0xcf3d0770, 0x3962f443, 0x405030b3,
    0xdfed11c1, 0xd4fb3366, 0xdb1db645, 0xb0a58278, 0x0f7200f9, 0xafcf7937, 0xa4d9f5ab, 0x7c0a4ffa,
    0x3da7ed8f, 0xd4749651, 0xcc5c599c, 0x5053dbd8, 0xa4226514, 0x3005318d, 0x1d1a494f, 0x54c8c706,
    0xefdad3a4, 0x3fade214, 0xe557ccac, 0x8075eba5, 0x1cdbaf08, 0xbf487d64, 0x59c16c5d, 0x62cbf1d1,
    0x3cd58567, 0xd794345e, 0xff1bf3d3, 0xe4b82129, 0x03181c59, 0x7ca258e9, 0x48709a7d, 0x6c1e596b,
    0xcde68124, 0x24f53341, 0x62b184e8, 0x36362666, 0xcd01d317, 0x8ddf51e5, 0xd67ea19d, 0xb6be0597,
    0x72691640, 0x512eb377, 0x63d0c384, 0x8db71a37, 0x38a8e1aa, 0x451a62f1, 0x110e0be7, 0xd3b7dd35,
    0xca75d298, 0xab532ddb, 0x856ff47f, 0x5e2357c4, 0x4c5303f0, 0x1be4e5e4, 0xc6734701, 0x88dd8405,
    0x0295e4f1, 0x081c875c, 0x005cb4e1, 0xe0036157, 0x6dc8cb79, 0x545f690e, 0x4fb29cc5, 0x4dd77bb2,
    0xbe158c7f, 0x73c3b6a7, 0x5815ac8c, 0x9e496d5c, 0x4baf2b6e, 0x46f8b459, 0x8189ef65, 0xf37cd94b,
    0x4ab89822, 0x0568412c, 0xc6e928f5, 0x466604b7, 0x3b6b286d, 0x34c1f8a0, 0x13a79531, 0x09cac61b,
    0x6fca7f40, 0x0b13c216, 0xc9beff6a, 0x89fd68e9, 0x47f5a9a9, 0x02d5189d, 0x4d4a1a4f, 0x83880a42,
    0xf3c1a485, 0x4639293d, 0x08b17bb3, 0xaa50f1e4, 0x3ff60a36, 0x1867f7b0, 0x71abe5b2, 0xf69a7e42,
    0x5c356d79, 0xc05ca232, 0xc016789d, 0x192346c3, 0xd9e1963d, 0x871aa13a, 0xff56263c, 0xf9451b8f,
    0x59651625, 0x9ec98a7b, 0x130204cd, 0x69872d7a, 0xe84618f6, 0x40bc5bbc, 0x5f177cf0, 0x521cb03e,
    0xe5b0c054, 0x141d509d, 0xfd0672a0, 0x1ab44a37, 0x8de66e6f, 0x7d89e3cb, 0x09b01186, 0x7381a70d,
    0xe3f3465c, 0x201d804c, 0xe9ad8c9d, 0xd1b7785a, 0xbd4f53e8, 0xff292fb5, 0x01f237e3, 0x73b02511,
};

q31_t ref_maxtrix_result[MAT_SIZE] = {
    0xf84cf2b8, 0x1536ab68, 0x0061195f, 0xfca81fb9, 0x0d8c7a53, 0x0dec5e3b, 0xf5b41d95, 0x00e59e7f,
    0x1a13101c, 0x01a576bf, 0x09c49345, 0xd6ada1e7, 0x0c86111d, 0x25d80f60, 0x14aa5962, 0x170e1386,
    0xf0f7277b, 0x0facf024, 0xfe83bde7, 0xfc111eca, 0xfc37a520, 0x24e81ef3, 0xf040feca, 0x1dae7005,
    0x106d63a3, 0x00c1d77f, 0xfc26b982, 0xd645e218, 0xfa88c2d8, 0x238eda3f, 0x14e584dd, 0x229fad0f,
    0xf73fceba, 0xfd06a467, 0xf471a945, 0xf7900747, 0x08503d1d, 0x09f5056a, 0xe775f417, 0x18d09235,
    0x141df628, 0xff60a630, 0xf1106a9c, 0xf216269b, 0x05af82e7, 0x24038a0e, 0x1c6a2b02, 0x2c7827f9,
    0xfc079d2f, 0x0e2a1cac, 0xf7c4f82d, 0xfd449c9a, 0x067b85a1, 0x07e663c3, 0xe782b934, 0x19450c43,
    0x294479db, 0xee67427d, 0x0304fab1, 0xe738de98, 0x01fe89f6, 0x344db25a, 0x170d4b73, 0x2629a60f,
    0xe7f74143, 0xfab77a1d, 0xf94564df, 0x07db2ce5, 0x14fb02da, 0xe97bf82b, 0xe88aeab7, 0x19b55658,
    0x2be1c0f4, 0xf2ad8359, 0x043f4db4, 0xe374b9b4, 0x0099d99e, 0x36b8b1c8, 0x27b15277, 0x2fd76638,
    0x14a583e6, 0x0a9c6ade, 0xf55dafb8, 0xe0121d67, 0xf22de778, 0x0a077139, 0xf9543d5e, 0x2042689d,
    0x191eb6fd, 0x0197d477, 0xfb45ee66, 0xf095bf67, 0xfc56d6aa, 0x2efad848, 0x1e58f161, 0x2f33a504,
    0x07e3ca2a, 0x02e27143, 0xfcbbda44, 0xf90fb8bb, 0x01d5a9af, 0x18209af4, 0xe5d3e3e9, 0x09628ecd,
    0x05492aa2, 0x042596a8, 0xfceed6b0, 0xef330357, 0x066391aa, 0x1e31ea2d, 0x1a506d4e, 0x1b121669,
    0xf7e03a16, 0xf9e8a6ff, 0xed1d7f79, 0xedd0db2b, 0x07346730, 0x02165c02, 0xff541fa3, 0x1d822d7b,
    0x17f22337, 0x000b151d, 0xf95ec677, 0xe5e6026f, 0xf399bf33, 0x26fc6384, 0x1fe2eadd, 0x2a40af9f,
    0xecf46eb9, 0xfb5f785b, 0xfc3a9f77, 0x027fa05e, 0xff8434d1, 0x01743688, 0xe2237bdf, 0x06dc8386,
    0x205f0c32, 0x042e03fd, 0x092defb6, 0xeee00701, 0xf7712120, 0x2a24dd5b, 0x0ff86daf, 0x150940a5,
    0xf0ab2782, 0xf5809187, 0xede587a2, 0x079f5995, 0xf0257e93, 0x1120c0bd, 0xf56c7863, 0x20e6a923,
    0x2562e598, 0x0177958f, 0xf8131c3e, 0xe0ccfab1, 0xf774ac44, 0x223bddc1, 0x13eeba7f, 0x33444b3d,
    0xeff739fc, 0x0e993e2f, 0xfc5754a5, 0xfb594b61, 0x163c5888, 0x05aabf1d, 0xf3ec9689, 0x108cb049,
    0x27089a02, 0xf75c5b20, 0xfd64fcb9, 0xe7ba2bb1, 0x02ae58e8, 0x30f8b69a, 0x0ce60bfa, 0x2161ef2c,
    0xee8e1ccb, 0x0bd7307d, 0x03e8273a, 0x14b8452b, 0x0b6bc589, 0x02fae097, 0xee953972, 0x00e02004,
    0x2248a558, 0xf66ae246, 0x0f9c419d, 0xe02205e3, 0xf5770a0b, 0x1eab85bd, 0x0615fb78, 0x0e1154d9,
    0xeb5a27f3, 0x056ea40d, 0x117b1f5b, 0x1c30094d, 0xee99d7e7, 0x1d0d8e17, 0xe4e39e5d, 0x092b35f2,
    0x0db00686, 0x1105b2f9, 0x0d030c67, 0xdfde0a2b, 0xf1a4520a, 0x1419f876, 0xf508dd03, 0x0c922ec4,
    0x0eb917cf, 0x068c4417, 0xf34053fd, 0xef91c79d, 0x065c4b00, 0x13787a20, 0xea690bec, 0x07d34771,
    0x200afc48, 0xffa2d732, 0xef4ef2e2, 0xf7cfd288, 0x15d56d20, 0x20c05f13, 0x1b2604f7, 0x2a082b91,
    0xf4c935d6, 0x05efad6c, 0x05eaf1bc, 0xfd2db7fc, 0xf26e9f00, 0x08dc79c5, 0xf0909be5, 0x18abe97e,
    0x1e13c538, 0xfb5266de, 0x07b1f059, 0xef81f822, 0xef5c9ba0, 0x204c0736, 0x07f0f4d9, 0x11354ca9,
    0xff4393b6, 0xffa0b5d3, 0xe6420adf, 0xfda29512, 0xf9e6c712, 0x14819176, 0xfb1eaf40, 0x1b72bdfe,
    0x12f85bde, 0xf29fc5c3, 0x055bc5ad, 0xde95cfd6, 0xf422392f, 0x1f219940, 0x091c01c1, 0x16ee7cf2,
};

q31_t maxtrix_result[MAT_SIZE];
int dsp_matrix_demo(void)
{
    csky_matrix_instance_q31 src0;
    csky_matrix_instance_q31 src1;
    csky_matrix_instance_q31 dst;
    int i;

    csky_mat_init_q31(&src0, MAT_ROW, MAT_COL, data_src0);
    csky_mat_init_q31(&src1, MAT_ROW, MAT_COL, data_src1);
    csky_mat_init_q31(&dst, MAT_ROW, MAT_COL, maxtrix_result);

    csky_mat_mult_q31(&src0, &src1, &dst);

    for (i = 0; i < MAT_SIZE; i++) {
        if (maxtrix_result[i] != ref_maxtrix_result[i]) {
            printf("dsp matrix cal run failure!\n");
            return -1;
        }
    }

    printf("dsp matrix cal run success!\n");
    return 0;
}



#define RFFT_TEST_SIZE 1024

q15_t rfft_src[RFFT_TEST_SIZE] = {
    0x4000, 0x44d9, 0x43e0, 0x3dc9, 0x33bb, 0x2735, 0x19e9, 0x0d90,
    0x03be, 0xfdbe, 0xfc6f, 0x002d, 0x08cc, 0x1596, 0x255f, 0x36a1,
    0x479d, 0x568c, 0x61c2, 0x67de, 0x67e9, 0x616d, 0x5488, 0x41e2,
    0x2aa8, 0x106c, 0xf506, 0xda68, 0xc271, 0xaec5, 0xa0a7, 0x98dc,
    0x979e, 0x9c93, 0xa6de, 0xb52e, 0xc5e5, 0xd73e, 0xe774, 0xf4f2,
    0xfe79, 0x033a, 0x02ea, 0xfdcc, 0xf4a7, 0xe8b0, 0xdb72, 0xcea1,
    0xc3f4, 0xbcf7, 0xbae6, 0xbe8d, 0xc831, 0xd789, 0xebc2, 0x038f,
    0x1d49, 0x370f, 0x4ef7, 0x6337, 0x724c, 0x7b21, 0x7d24, 0x7854,
    0x6d41, 0x5cfe, 0x4906, 0x3319, 0x1d14, 0x08c4, 0xf7bc, 0xeb31,
    0xe3dd, 0xe1f4, 0xe519, 0xec73, 0xf6b9, 0x025b, 0x0da4, 0x16ec,
    0x1cb9, 0x1dec, 0x19db, 0x1063, 0x01ef, 0xef6c, 0xda38, 0xc404,
    0xaea7, 0x9bf7, 0x8d9f, 0x84f4, 0x82d5, 0x879b, 0x9309, 0xa457,
    0xba41, 0xd322, 0xed1f, 0x064a, 0x1cd8, 0x2f3f, 0x3c61, 0x43a0,
    0x44ee, 0x40c6, 0x3823, 0x2c68, 0x1f36, 0x1248, 0x0746, 0xff9e,
    0xfc5c, 0xfe12, 0x04cc, 0x1009, 0x1eca, 0x2fa8, 0x40f8, 0x50ee,
    0x5dd1, 0x661c, 0x68a9, 0x64cf, 0x5a6e, 0x49f8, 0x3467, 0x1b2a,
    0x0000, 0xe4d6, 0xcb99, 0xb608, 0xa592, 0x9b31, 0x9757, 0x99e4,
    0xa22f, 0xaf12, 0xbf08, 0xd058, 0xe136, 0xeff7, 0xfb34, 0x01ee,
    0x03a4, 0x0062, 0xf8ba, 0xedb8, 0xe0ca, 0xd398, 0xc7dd, 0xbf3a,
    0xbb12, 0xbc60, 0xc39f, 0xd0c1, 0xe328, 0xf9b6, 0x12e1, 0x2cde,
    0x45bf, 0x5ba9, 0x6cf7, 0x7865, 0x7d2b, 0x7b0c, 0x7261, 0x6409,
    0x5159, 0x3bfc, 0x25c8, 0x1094, 0xfe11, 0xef9d, 0xe625, 0xe214,
    0xe347, 0xe914, 0xf25c, 0xfda5, 0x0947, 0x138d, 0x1ae7, 0x1e0c,
    0x1c23, 0x14cf, 0x0844, 0xf73c, 0xe2ec, 0xcce7, 0xb6fa, 0xa302,
    0x92bf, 0x87ac, 0x82dc, 0x84df, 0x8db4, 0x9cc9, 0xb109, 0xc8f1,
    0xe2b7, 0xfc71, 0x143e, 0x2877, 0x37cf, 0x4173, 0x451a, 0x4309,
    0x3c0c, 0x315f, 0x248e, 0x1750, 0x0b59, 0x0234, 0xfd16, 0xfcc6,
    0x0187, 0x0b0e, 0x188c, 0x28c2, 0x3a1b, 0x4ad2, 0x5922, 0x636d,
    0x6862, 0x6724, 0x5f59, 0x513b, 0x3d8f, 0x2598, 0x0afa, 0xef94,
    0xd558, 0xbe1e, 0xab78, 0x9e93, 0x9817, 0x9822, 0x9e3e, 0xa974,
    0xb863, 0xc95f, 0xdaa1, 0xea6a, 0xf734, 0xffd3, 0x0391, 0x0242,
    0xfc42, 0xf270, 0xe617, 0xd8cb, 0xcc45, 0xc237, 0xbc20, 0xbb27,
    0xc000, 0xcad3, 0xdb3a, 0xf048, 0x089c, 0x227f, 0x3c0d, 0x535d,
    0x66b0, 0x7497, 0x7c16, 0x7cb7, 0x7696, 0x6a60, 0x593e, 0x44bc,
    0x2ea4, 0x18d3, 0x050e, 0xf4d6, 0xe94b, 0xe30d, 0xe232, 0xe645,
    0xee51, 0xf8fe, 0x04b2, 0x0fb6, 0x1867, 0x1d5c, 0x1d8b, 0x1864,
    0x0de0, 0xfe84, 0xeb58, 0xd5cd, 0xbf9e, 0xaaa5, 0x98b4, 0x8b66,
    0x83fc, 0x833c, 0x8960, 0x960f, 0xa867, 0xbf0d, 0xd84e, 0xf248,
    0x0b11, 0x20e6, 0x3252, 0x3e4f, 0x445b, 0x4482, 0x3f5d, 0x35fe,
    0x29d4, 0x1c8c, 0x0fe0, 0x0570, 0xfe96, 0xfc4b, 0xff06, 0x06b6,
    0x12bf, 0x220b, 0x3324, 0x4453, 0x53ce, 0x5fe2, 0x671b, 0x686a,
    0x6340, 0x5799, 0x4606, 0x2f99, 0x15d3, 0xfa81, 0xdf93, 0xc6f0,
    0xb24b, 0xa2fd, 0x99e5, 0x975a, 0x9b1f, 0xa470, 0xb212, 0xc272,
    0xd3cf, 0xe461, 0xf288, 0xfcef, 0x02ae, 0x0361, 0xff2d, 0xf6c0,
    0xeb3d, 0xde1e, 0xd113, 0xc5d7, 0xbe00, 0xbadf, 0xbd57, 0xc5ca,
    0xd40b, 0xe761, 0xfe97, 0x1813, 0x31fe, 0x4a6c, 0x5f89, 0x6fc1,
    0x79e6, 0x7d4b, 0x79d1, 0x6fed, 0x6098, 0x4d3c, 0x378d, 0x2167,
    0x0c9d, 0xfad1, 0xed4c, 0xe4e5, 0xe1e9, 0xe41a, 0xeab3, 0xf482,
    0x0000, 0x0b7e, 0x154d, 0x1be6, 0x1e17, 0x1b1b, 0x12b4, 0x052f,
    0xf363, 0xde99, 0xc873, 0xb2c4, 0x9f68, 0x9013, 0x862f, 0x82b5,
    0x861a, 0x903f, 0xa077, 0xb594, 0xce02, 0xe7ed, 0x0169, 0x189f,
    0x2bf5, 0x3a36, 0x42a9, 0x4521, 0x4200, 0x3a29, 0x2eed, 0x21e2,
    0x14c3, 0x0940, 0x00d3, 0xfc9f, 0xfd52, 0x0311, 0x0d78, 0x1b9f,
    0x2c31, 0x3d8e, 0x4dee, 0x5b90, 0x64e1, 0x68a6, 0x661b, 0x5d03,
    0x4db5, 0x3910, 0x206d, 0x057f, 0xea2d, 0xd067, 0xb9fa, 0xa867,
    0x9cc0, 0x9796, 0x98e5, 0xa01e, 0xac32, 0xbbad, 0xccdc, 0xddf5,
    0xed41, 0xf94a, 0x00fa, 0x03b5, 0x016a, 0xfa90, 0xf020, 0xe374,
    0xd62c, 0xca02, 0xc0a3, 0xbb7e, 0xbba5, 0xc1b1, 0xcdae, 0xdf1a,
    0xf4ef, 0x0db8, 0x27b2, 0x40f3, 0x5799, 0x69f1, 0x76a0, 0x7cc4,
    0x7c04, 0x749a, 0x674c, 0x555b, 0x4062, 0x2a33, 0x14a8, 0x017c,
    0xf220, 0xe79c, 0xe275, 0xe2a4, 0xe799, 0xf04a, 0xfb4e, 0x0702,
    0x11af, 0x19bb, 0x1dce, 0x1cf3, 0x16b5, 0x0b2a, 0xfaf2, 0xe72d,
    0xd15c, 0xbb44, 0xa6c2, 0x95a0, 0x896a, 0x8349, 0x83ea, 0x8b69,
    0x9950, 0xaca3, 0xc3f3, 0xdd81, 0xf764, 0x0fb8, 0x24c6, 0x352d,
    0x4000, 0x44d9, 0x43e0, 0x3dc9, 0x33bb, 0x2735, 0x19e9, 0x0d90,
    0x03be, 0xfdbe, 0xfc6f, 0x002d, 0x08cc, 0x1596, 0x255f, 0x36a1,
    0x479d, 0x568c, 0x61c2, 0x67de, 0x67e9, 0x616d, 0x5488, 0x41e2,
    0x2aa8, 0x106c, 0xf506, 0xda68, 0xc271, 0xaec5, 0xa0a7, 0x98dc,
    0x979e, 0x9c93, 0xa6de, 0xb52e, 0xc5e5, 0xd73e, 0xe774, 0xf4f2,
    0xfe79, 0x033a, 0x02ea, 0xfdcc, 0xf4a7, 0xe8b0, 0xdb72, 0xcea1,
    0xc3f4, 0xbcf7, 0xbae6, 0xbe8d, 0xc831, 0xd789, 0xebc2, 0x038f,
    0x1d49, 0x370f, 0x4ef7, 0x6337, 0x724c, 0x7b21, 0x7d24, 0x7854,
    0x6d41, 0x5cfe, 0x4906, 0x3319, 0x1d14, 0x08c4, 0xf7bc, 0xeb31,
    0xe3dd, 0xe1f4, 0xe519, 0xec73, 0xf6b9, 0x025b, 0x0da4, 0x16ec,
    0x1cb9, 0x1dec, 0x19db, 0x1063, 0x01ef, 0xef6c, 0xda38, 0xc404,
    0xaea7, 0x9bf7, 0x8d9f, 0x84f4, 0x82d5, 0x879b, 0x9309, 0xa457,
    0xba41, 0xd322, 0xed1f, 0x064a, 0x1cd8, 0x2f3f, 0x3c61, 0x43a0,
    0x44ee, 0x40c6, 0x3823, 0x2c68, 0x1f36, 0x1248, 0x0746, 0xff9e,
    0xfc5c, 0xfe12, 0x04cc, 0x1009, 0x1eca, 0x2fa8, 0x40f8, 0x50ee,
    0x5dd1, 0x661c, 0x68a9, 0x64cf, 0x5a6e, 0x49f8, 0x3467, 0x1b2a,
    0x0000, 0xe4d6, 0xcb99, 0xb608, 0xa592, 0x9b31, 0x9757, 0x99e4,
    0xa22f, 0xaf12, 0xbf08, 0xd058, 0xe136, 0xeff7, 0xfb34, 0x01ee,
    0x03a4, 0x0062, 0xf8ba, 0xedb8, 0xe0ca, 0xd398, 0xc7dd, 0xbf3a,
    0xbb12, 0xbc60, 0xc39f, 0xd0c1, 0xe328, 0xf9b6, 0x12e1, 0x2cde,
    0x45bf, 0x5ba9, 0x6cf7, 0x7865, 0x7d2b, 0x7b0c, 0x7261, 0x6409,
    0x5159, 0x3bfc, 0x25c8, 0x1094, 0xfe11, 0xef9d, 0xe625, 0xe214,
    0xe347, 0xe914, 0xf25c, 0xfda5, 0x0947, 0x138d, 0x1ae7, 0x1e0c,
    0x1c23, 0x14cf, 0x0844, 0xf73c, 0xe2ec, 0xcce7, 0xb6fa, 0xa302,
    0x92bf, 0x87ac, 0x82dc, 0x84df, 0x8db4, 0x9cc9, 0xb109, 0xc8f1,
    0xe2b7, 0xfc71, 0x143e, 0x2877, 0x37cf, 0x4173, 0x451a, 0x4309,
    0x3c0c, 0x315f, 0x248e, 0x1750, 0x0b59, 0x0234, 0xfd16, 0xfcc6,
    0x0187, 0x0b0e, 0x188c, 0x28c2, 0x3a1b, 0x4ad2, 0x5922, 0x636d,
    0x6862, 0x6724, 0x5f59, 0x513b, 0x3d8f, 0x2598, 0x0afa, 0xef94,
    0xd558, 0xbe1e, 0xab78, 0x9e93, 0x9817, 0x9822, 0x9e3e, 0xa974,
    0xb863, 0xc95f, 0xdaa1, 0xea6a, 0xf734, 0xffd3, 0x0391, 0x0242,
    0xfc42, 0xf270, 0xe617, 0xd8cb, 0xcc45, 0xc237, 0xbc20, 0xbb27,
    0xc000, 0xcad3, 0xdb3a, 0xf048, 0x089c, 0x227f, 0x3c0d, 0x535d,
    0x66b0, 0x7497, 0x7c16, 0x7cb7, 0x7696, 0x6a60, 0x593e, 0x44bc,
    0x2ea4, 0x18d3, 0x050e, 0xf4d6, 0xe94b, 0xe30d, 0xe232, 0xe645,
    0xee51, 0xf8fe, 0x04b2, 0x0fb6, 0x1867, 0x1d5c, 0x1d8b, 0x1864,
    0x0de0, 0xfe84, 0xeb58, 0xd5cd, 0xbf9e, 0xaaa5, 0x98b4, 0x8b66,
    0x83fc, 0x833c, 0x8960, 0x960f, 0xa867, 0xbf0d, 0xd84e, 0xf248,
    0x0b11, 0x20e6, 0x3252, 0x3e4f, 0x445b, 0x4482, 0x3f5d, 0x35fe,
    0x29d4, 0x1c8c, 0x0fe0, 0x0570, 0xfe96, 0xfc4b, 0xff06, 0x06b6,
    0x12bf, 0x220b, 0x3324, 0x4453, 0x53ce, 0x5fe2, 0x671b, 0x686a,
    0x6340, 0x5799, 0x4606, 0x2f99, 0x15d3, 0xfa81, 0xdf93, 0xc6f0,
    0xb24b, 0xa2fd, 0x99e5, 0x975a, 0x9b1f, 0xa470, 0xb212, 0xc272,
    0xd3cf, 0xe461, 0xf288, 0xfcef, 0x02ae, 0x0361, 0xff2d, 0xf6c0,
    0xeb3d, 0xde1e, 0xd113, 0xc5d7, 0xbe00, 0xbadf, 0xbd57, 0xc5ca,
    0xd40b, 0xe761, 0xfe97, 0x1813, 0x31fe, 0x4a6c, 0x5f89, 0x6fc1,
    0x79e6, 0x7d4b, 0x79d1, 0x6fed, 0x6098, 0x4d3c, 0x378d, 0x2167,
    0x0c9d, 0xfad1, 0xed4c, 0xe4e5, 0xe1e9, 0xe41a, 0xeab3, 0xf482,
    0x0000, 0x0b7e, 0x154d, 0x1be6, 0x1e17, 0x1b1b, 0x12b4, 0x052f,
    0xf363, 0xde99, 0xc873, 0xb2c4, 0x9f68, 0x9013, 0x862f, 0x82b5,
    0x861a, 0x903f, 0xa077, 0xb594, 0xce02, 0xe7ed, 0x0169, 0x189f,
    0x2bf5, 0x3a36, 0x42a9, 0x4521, 0x4200, 0x3a29, 0x2eed, 0x21e2,
    0x14c3, 0x0940, 0x00d3, 0xfc9f, 0xfd52, 0x0311, 0x0d78, 0x1b9f,
    0x2c31, 0x3d8e, 0x4dee, 0x5b90, 0x64e1, 0x68a6, 0x661b, 0x5d03,
    0x4db5, 0x3910, 0x206d, 0x057f, 0xea2d, 0xd067, 0xb9fa, 0xa867,
    0x9cc0, 0x9796, 0x98e5, 0xa01e, 0xac32, 0xbbad, 0xccdc, 0xddf5,
    0xed41, 0xf94a, 0x00fa, 0x03b5, 0x016a, 0xfa90, 0xf020, 0xe374,
    0xd62c, 0xca02, 0xc0a3, 0xbb7e, 0xbba5, 0xc1b1, 0xcdae, 0xdf1a,
    0xf4ef, 0x0db8, 0x27b2, 0x40f3, 0x5799, 0x69f1, 0x76a0, 0x7cc4,
    0x7c04, 0x749a, 0x674c, 0x555b, 0x4062, 0x2a33, 0x14a8, 0x017c,
    0xf220, 0xe79c, 0xe275, 0xe2a4, 0xe799, 0xf04a, 0xfb4e, 0x0702,
    0x11af, 0x19bb, 0x1dce, 0x1cf3, 0x16b5, 0x0b2a, 0xfaf2, 0xe72d,
    0xd15c, 0xbb44, 0xa6c2, 0x95a0, 0x896a, 0x8349, 0x83ea, 0x8b69,
    0x9950, 0xaca3, 0xc3f3, 0xdd81, 0xf764, 0x0fb8, 0x24c6, 0x352d,
};

q15_t ref_rfft_result[RFFT_TEST_SIZE + 2] = {
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0xe000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x2000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000,
    0x0000, 0x0000,
};

int dsp_rfft_demo(void)
{
    int i;
    int err;
    q15_t result[RFFT_TEST_SIZE + 2];

    csky_rfft_q15(&csky_rfft_sR_q15_len1024, rfft_src, result);

    for (i = 0; i < RFFT_TEST_SIZE + 2; i++) {
        err = abs(result[i] - ref_rfft_result[i]);
        if (err > 0xf) {
            printf("dsp rfft run failure!\n");
            return -1;
        }
    }

    printf("dsp rfft run success!\n");

    return 0;
}


#define SIN_TEST_SIZE 128

q31_t sin_src[SIN_TEST_SIZE] = {
    0x71f40eb8, 0x1aedfac4, 0x0f3ff639, 0x40eb378a, 0x159f1974, 0x5428ca42, 0x3e990f9d, 0x209a58e6,
    0x62875be9, 0x5816212a, 0x28a6ff13, 0x7a51f6a7, 0x3ca51dcd, 0x052989e9, 0x613a6877, 0x413bbd0c,
    0x502a2298, 0x44af92d2, 0x1851b3ba, 0x531d1932, 0x5259e962, 0x36537413, 0x457bf10d, 0x6f43906c,
    0x473fcc60, 0x3ed09220, 0x2a151a9b, 0x12b52c1b, 0x3f79f6a8, 0x0aea56a5, 0x7f5ab471, 0x0ee05125,
    0x2ec0f1de, 0x2b59847b, 0x6da9fe05, 0x0aa207c9, 0x4e0db117, 0x1ad037ab, 0x78555489, 0x2005ef5a,
    0x107b129e, 0x36df9796, 0x4687e80b, 0x732d0ac1, 0x534c3c63, 0x1c0f8e39, 0x30b19f31, 0x19f18910,
    0x3850eca4, 0x10118818, 0x45a0df62, 0x4104e5c3, 0x14195691, 0x74162b17, 0x5b9f737e, 0x445d0125,
    0x1df54a61, 0x788e5af7, 0x3bc0bd34, 0x0f07e8f3, 0x211f4d64, 0x31a834bb, 0x506dd274, 0x6bb74d4b,
    0x66e132bc, 0x263e92dd, 0x5cb47ec9, 0x541f4af5, 0x2320126d, 0x58b7700e, 0x00d0828f, 0x1182b519,
    0x3d33cf33, 0x6577c618, 0x22af9e0f, 0x058ffea4, 0x2bf32d25, 0x07fb97e5, 0x7895e5f5, 0x73b5f4dd,
    0x0399834c, 0x52f68eac, 0x66311a01, 0x3690ee7d, 0x1258b0e3, 0x1d85a331, 0x28e0511a, 0x1485ae28,
    0x556e56c5, 0x690aa18a, 0x040672e5, 0x5c14209e, 0x5d8ff577, 0x61ba1095, 0x27c2e01e, 0x797a7a8f,
    0x2d957473, 0x2a0c920a, 0x5b8d5230, 0x4c5e6a70, 0x62c33c82, 0x552b8cf0, 0x52a5adae, 0x3023134c,
    0x2015d046, 0x734945c9, 0x73233bd0, 0x4e0a9921, 0x52fc390d, 0x02b26459, 0x25ea9d61, 0x4197a318,
    0x55b9ca53, 0x6eb23e44, 0x31862277, 0x7b8f7be8, 0x2c0cc008, 0x533a8b83, 0x6a35c724, 0x0a232bc0,
    0x2e6247d9, 0x3b442980, 0x1de30e64, 0x749b41b2, 0x70834a66, 0x01f8428b, 0x56356d0a, 0x4708a91b,
};

q31_t ref_sin_result[SIN_TEST_SIZE] = {
    0xae927d72, 0x7c0dcc9a, 0x571dc1b4, 0xfa3a9ce8, 0x6fbe4766, 0x950553ac, 0x08cd75d4, 0x7ff10d88,
    0x80fc5f3e, 0x8989e528, 0x74a02914, 0xdcc60f08, 0x14fc107a, 0x2016c0b4, 0x803bb9f2, 0xf841608c,
    0xa4c37a12, 0xe2d13fdc, 0x7701f3ce, 0x98c47cba, 0x9babda5e, 0x3a861816, 0xddf4f932, 0xa247ba02,
    0xd36834fe, 0x0771665a, 0x70a392a6, 0x65b47542, 0x034a13ca, 0x4158f3d2, 0xfbf19cc6, 0x55615368,
    0x5fdfbdea, 0x6ca44370, 0x9bbb0ff4, 0x3fd0ad96, 0xae8a0976, 0x7bdf3ff8, 0xd0f56b9a, 0x7fffc56a,
    0x5c9ea4d4, 0x3771a934, 0xd7aa340e, 0xb4a477aa, 0x9816491c, 0x7d9cd9ea, 0x575fbe36, 0x7a621b14,
    0x2f245878, 0x5acfe2d2, 0xdd15a2fa, 0xf9996cf4, 0x6ac53b20, 0xb9575c24, 0x82f21454, 0xe4cb524a,
    0x7f5b34f4, 0xd2434f50, 0x1a7e13a4, 0x561a435e, 0x7fcdac80, 0x52dadf6a, 0xa39b2218, 0x94978822,
    0x873b677e, 0x7a08961a, 0x81ac072c, 0x95262c98, 0x7e7e8b94, 0x8818541c, 0x051dbcf2, 0x60f7405a,
    0x1185c64c, 0x849581a0, 0x7ee31fd6, 0x2284557a, 0x6a99f2be, 0x30e22044, 0xd26fa1a0, 0xb76248d4,
    0x167fd962, 0x9954214a, 0x85de5864, 0x392d8c3e, 0x644f642a, 0x7f0db084, 0x7409edc4, 0x6c371202,
    0x90d846b8, 0x8c670202, 0x19206920, 0x825db7b6, 0x80eac460, 0x8075db58, 0x76d279d2, 0xd7b86778,
    0x6494f30e, 0x70bd232c, 0x830a5b0a, 0xb6f92e88, 0x812cf66e, 0x91aab728, 0x9a86f676, 0x59e5afda,
    0x7fff28b2, 0xb53400a0, 0xb472be58, 0xae98fc86, 0x993ebfe8, 0x10e525f8, 0x7aa33c5c, 0xf60164b2,
    0x8feff520, 0x9fe370c6, 0x537dd3cc, 0xe4538b3e, 0x6a40ae5e, 0x98572fc8, 0x8fbe4fce, 0x3d18f9cc,
    0x61655134, 0x1d79d4fc, 0x7f4f471a, 0xbc1671de, 0xa7cc325e, 0x0c5b6644, 0x8e80c89c, 0xd4adac08,
};


int32_t dsp_sin_demo(void)
{
    q31_t result;
    int i;

    for (i = 0; i < SIN_TEST_SIZE; i++) {
        result = csky_sin_q31(sin_src[i]);

        if (result != ref_sin_result[i]) {
            printf("dsp sin run failure!\n");
			return -1;
        }
    }

    printf("dsp sin run success!\n");

    return 0;
}



#define VARIANCE_STATIS_SIZE 128

q15_t variance_src[VARIANCE_STATIS_SIZE] = {
 0x0af7, 0x2217, 0xd65a, 0x0066, 0xf0fb, 0x3d15, 0x37d2, 0x3245,
 0xf8c6, 0x2032, 0x3467, 0xefc9, 0xcee3, 0x0337, 0xebaa, 0x2cb9,
 0xd7d6, 0xdab8, 0x03e5, 0xcaca, 0xded2, 0x1139, 0xce38, 0x0dbd,
 0x31e4, 0xfecf, 0xe821, 0x218e, 0x3a2e, 0x12ac, 0xfe1f, 0xf816,
 0xd7db, 0xf8b9, 0xfe7b, 0x2e3a, 0x1bb5, 0x0f67, 0xcb7e, 0xce4e,
 0x09ad, 0xfb18, 0x05d1, 0xc4de, 0x0a26, 0x1082, 0xfdb0, 0xd48c,
 0x208f, 0x2591, 0xe54c, 0x00f9, 0xde77, 0xd8aa, 0x2783, 0xc889,
 0xd912, 0x3cc6, 0x099d, 0x0aa7, 0x399a, 0xccce, 0x307a, 0x321b,
 0xdb66, 0xd55f, 0x12b4, 0xd715, 0xceeb, 0xeec3, 0xf381, 0xcb7f,
 0x1786, 0x0601, 0x3e34, 0xdb3b, 0x35a1, 0x1524, 0x1f2a, 0xf071,
 0xfcc5, 0xcd9a, 0x3120, 0xf8f9, 0x1589, 0x1d36, 0xe490, 0x0bfe,
 0xef6e, 0x25d7, 0xc96a, 0x3f12, 0x2355, 0xc0f2, 0x31c9, 0x2e9c,
 0x194b, 0x3147, 0xfb9a, 0xef8f, 0xcaa0, 0x3fa5, 0x2f57, 0xc002,
 0x1709, 0x13d3, 0xf4b6, 0xfcfa, 0xf1b3, 0xf9dd, 0xc36d, 0xf670,
 0xcd8b, 0xc585, 0x072f, 0x0e3f, 0x1e92, 0xe0e3, 0x1cf6, 0x1b4c,
 0x007b, 0x3246, 0x23c3, 0xff58, 0x2179, 0x1562, 0x3d33, 0xcefc,
};

int dsp_variance_demo(void)
{
    q15_t result;
    q15_t ref_result = 0xa8b;
    csky_var_q15(variance_src, VARIANCE_STATIS_SIZE, &result);

    if (result == ref_result) {
        printf("dsp variance run success!\n");
    } else {
        printf("dsp variance run failure!\n");
    }

    return 0;
}

int dsp_demo(u8 func)
{
	switch(func)
	{
		case 0:
			dsp_fir_demo();
			break;
		case 1:
			dsp_matrix_demo();
			break;
		case 2:
			dsp_rfft_demo();
			break;
		case 3:
			dsp_sin_demo();
			break;
		case 4:
			dsp_variance_demo();
			break;
		default:
			printf("no demo for this func no!!!\r\n");
			break;
	}
	return 0;
}

#endif





